package com.mr3chi.horoscopes;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class News {
	
	private static final String DATE_FORMAT = "dd-MM-yyyy hh:mm:ss";
	private static final String SHOW_DATE_FORMAT = "MMMM, dd yyyy hh:mm:ss";
	
	private int id;
	private String title;
	private String image;
	private String desc;
	private String link;
	private String pageId;
	private Date postDate;
	
	public News() {
		id = 0;
		title = "";
		image = "";
		desc = "";
		link = "";
		pageId = "";
		postDate = new Date();
	}
	
	public News(String title, String image, String desc, String link, String pageId, Date date) {
		id 			= 0;
		this.title 	= title;
		this.image 	= image;
		this.desc 	= desc;
		this.link 	= link;
		this.pageId	= pageId;
		this.postDate = date;
	}
	
	public News(int id, String title, String image, String desc, String link, String pageId, Date date) {
		this.id 	= id;
		this.title 	= title;
		this.image 	= image;
		this.desc 	= desc;
		this.link 	= link;
		this.pageId	= pageId;
		this.postDate = date;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getImage() {
		return image;
	}
	public void setImage(String image) {
		this.image = image;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public String getLink() {
		return link;
	}
	public void setLink(String link) {
		this.link = link;
	}
	public String getPageId() {
		return pageId;
	}
	public void setPageId(String pageId) {
		this.pageId = pageId;
	}
	public Date getDate() {
		return postDate;
	}
	public void setDate(Date postTime) {
		this.postDate = postTime;
	}
	
	public String getDateString(){
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
		return sdf.format(postDate);
	}
	
	public void setDateString(String date){
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
		try {
			postDate = sdf.parse(date);
		} catch (ParseException e) {
			postDate = new Date();
		}
	}
	
	public String getShowOffString(){
		SimpleDateFormat sdf = new SimpleDateFormat(SHOW_DATE_FORMAT, Locale.US);
		return sdf.format(postDate);
	}
}
